<template>
  <div class="gameStatusCheck all scroolBar "   style="overflow-y: auto;">
    <!-- 筛选组件-->
    <div>
      <el-dropdown @command="getCommand">
        <el-button type="primary">
          筛选搜索<i class="el-icon-arrow-down el-icon--right"></i>
        </el-button>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="">全部</el-dropdown-item>
          <el-dropdown-item command="0">待审核</el-dropdown-item>
          <el-dropdown-item command="1">审核通过</el-dropdown-item>
          <el-dropdown-item command="2">审核失败</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>

    <!-- 表格组件-->
    <div>
      <myTable :tabelHeader="tableHeader" :tableData="statusList" @tableCellClick="onMoudelMsg"></myTable>
    </div>
    <!-- 分页组件 -->
    <div class="workCenterRig">
      <table-paper :currPageNum="pageNum" :PagerOrder="PagerOrder"  @tablePaperEven="onMoudelMsg" ></table-paper>
    </div>
  </div>
</template>

<script>
  import {
    deleteGameZone,
    getGameInfoList,
    putGameStatus
  } from './api'
  import myTable from './../../components/yqq/table'
  import tablePaper from '../../components/yqq/tablePaper'
  import Cookies from 'js-cookie'
  var  adminName=Cookies.get('adminName')
  var  token=Cookies.get('token')
  export default {
    name: "gameStatusCheck",
    components: {
      "myTable":myTable,
      tablePaper,
    },
    data(){
      return{
        form:{
          name:'',//区服名称
        },
        status:'',     //0-待审核 1-审核通过 2-审核失败
        dialogVisible:false,//对话框展示
        title:"提示", //对话框标题
        pageNum:1,//页码
        pageSize:10,//个数
        PagerOrder:{
          count:0,
        },
        statusList:[],//状态列表
        //表头数据
        tableHeader:[{
          type:'text',
          key:'introduce',
          value:'介绍',
        },{
          type:'text',
          key:'statusName',
          value:'状态',
        },
          {
            type: 'button',
            key: 'primary',
            value: '操作',
            btnLis:[
              {
                name:'审核通过',
                judeKey:'primary',
                judeValue:'primary',
                type:'success',
                btntype:'success',
              },
              {
                name:'审核失败',
                judeKey:'primary',
                judeValue:'primary',
                type:'failure',
                btntype:'warning',
              },
            ]}],
      }
    },
    created() {
      this.getGameInfoList()
    },
    methods:{
      //表格组件事件
      onMoudelMsg(data){
        // console.log(data)
        let btnType = data.type
        let itemData = data.data
        if(btnType == 'paperNumChange'){
          this.pageNum = itemData
          this.getGameInfoList()
        }

        if(btnType == 'success'){
          this.$confirmMsg("确定更改状态为审核成功吗？",'','success',()=>{
            putGameStatus({infoId:itemData.infoId,status:1}) .then((res)=>{
              if (res.code==0){
                this.$notifyMsg("提示","更改状态为审核通过！","success")
                this.getGameInfoList()
              }else {
                this.$notifyMsg("提示","更改失败!","error")
              }
            })
          },()=>{},)
        }

        if(btnType == 'failure'){
          this.$confirmMsg("确定更改状态为审核失败吗？",'','',()=>{
            putGameStatus({infoId:itemData.infoId,status:2}) .then((res)=>{
              if (res.code==0){
                this.$notifyMsg("提示","更改状态为审核失败！","success")
                this.getGameInfoList()
              }else {
                this.$notifyMsg("提示","更改失败!","error")
              }
            })
          },()=>{},)
        }


      },

      //搜索状态
      getCommand(command){
        // console.log(command)
        this.status=command
        this.pageNum=1//页码
        this.pageSize=10//个数
        this.PagerOrder={
          count:0,
        }
          this.getGameInfoList()
      },

      //审核列表
      getGameInfoList(){
        var getObj = {
          pageNum:this.pageNum,
          pageSize:this.pageSize,
          status:this.status
        }
        getGameInfoList(getObj).then(res=>{
          // console.log("获取审核列表res",res)
          var vdata = res.data.list

          vdata.forEach((items,i)=>{
            // //0-待审核 1-审核通过 2-审核失败
            if (items.status==0){
              items.primary = 'primary' //待审核时候按钮默认显示
              items.statusName = '待审核'
            }
            if (items.status==1){
              items.statusName = '审核通过'
            }
            if (items.status==2){
              items.statusName = '审核失败'
            }
          })

          this.statusList = vdata
          this.PagerOrder={
            count:res.data.total,
            size:this.pageSize
          }

        }).catch(err=>{
          // console.log("获取审核列表err",err)
        })
      },
    },

  };
</script>

<style scoped>
  .gameStatusCheck .el-input { width:auto;}
  .gameStatusCheck .el-input-number{width: auto}
  .gameStatusCheck::-webkit-scrollbar {
    display: block;
  }
  .gameStatusCheck .avatar-uploader .el-upload {
    border: 1px dashed lightgray;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .gameStatusCheck .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .gameStatusCheck .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .gameStatusCheck .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>
